using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace GraphMyCode.Controls
{
	public class SelectionControl : ContentControl
	{
		private readonly Path path;
		private Point endPoint;

		public SelectionControl()
		{
			path = new Path
			       	{
			       		Stroke = new SolidColorBrush(new Color { A = 255, B = 215, G = 167, R = 100 }),
			       		Fill = new SolidColorBrush(new Color { A = 100, B = 215, G = 167, R = 100 })
			       	};
			Content = path;
		}

		public Point EndPoint
		{
			get { return endPoint; }
			set
			{
				if (endPoint != value)
				{
					endPoint = value;
					Bounds = new Rect(StartPoint, endPoint);
					path.Data = new RectangleGeometry { Rect = Bounds };
				}
			}
		}

		public Point StartPoint { get; set; }

		public Rect Bounds;

		public void ClearSelection()
		{
			StartPoint = new Point(0, 0);
			EndPoint = new Point(0, 0);
		}
	}
}